<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
	String ctx = request.getContextPath();
%>

<html>
	<head>
		<title>JS学习</title>
		<jsp:include page="/pages/common/include.jsp"></jsp:include>
		<style type="text/css">
			*.* {
				font-size: 12px;
				overflow-x: hidden;
			}
		</style>
		<script type="text/javascript">
			$(function() {
				$("#cookieBtn").click(function() {
					var cNm = $("#cookieNm").val();
					var cVal = $("#cookieVal").val();
					
				});
			});
				function createCookie(name,value,days)
				{
					if (days)
					{
						var date = new Date();
						date.setTime(date.getTime()+(days*24*60*60*1000));
						var expires = "; expires="+date.toGMTString();
					}
					else var expires = "";
					document.cookie = name+"="+value+expires+"; path=/";
				}
				function readCookie(name)
				{
					var nameEQ = name + "=";
					var ca = document.cookie.split(';');
					for(var i=0;i < ca.length;i++)
					{
						var c = ca[i];
						while (c.charAt(0)==' ') c = c.substring(1,c.length);
						if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
					}
					return null;
				}
		</script>
	</head>

	<body>
		<h2>Cookie操作</h2>
		<fieldset>
			<p>
				<label style="width:150px; display: inline-block;">cookie name:</label>
				<input type="text" id="cookieNm" value="" style="display: inline-block" />
			</p>
			<p>
				<label style="width:150px; display: inline-block;">cookie value:</label>
				<input type="text" id="cookieVal" value="" style="display: inline-block" />
			</p>
			<p>
				<input type="button" id="cookieBtn" value="添加" />
			</p>
		</fieldset>
		<h2>全部Cookie</h2>
		<div id="cookieDiv">
		</div>
	</body>
</html>